package com.zzh.tools;

import android.content.Context;
import android.text.TextUtils;

import com.zzh.tools.define_throw.InitException;


/**
 * @author zhangzhihao
 * @email zhangzhihao@gongjiangren.net
 * @date 2020-08-29
 * @desc
 */
public class Tools {

    private static class ToolsHelper {
        static Tools tools = new Tools();
    }

    private Tools() {

    }

    public static Tools getInstance() {
        return ToolsHelper.tools;
    }

    private Context mContext;
    private String defaultShareName = "share_default";

    public Context getContext() {
        if (mContext == null) {
            throw new InitException("tools 没有传入context");
        }
        return mContext;
    }

    public String getDefaultShareName() {
        return defaultShareName;
    }

    static class Buider {
        private String defaultShareName;

        public Buider setDefaultShareName(String defaultShareName) {
            this.defaultShareName = defaultShareName;
            return this;
        }

        public Tools buider(Context context) {
            Tools tools = Tools.getInstance();
            tools.mContext = context;
            if (!TextUtils.isEmpty(defaultShareName)) {
                tools.defaultShareName = defaultShareName;
            }
            return tools;
        }
    }

    public static final void print(String msg) {
        System.out.println(">>>>1.0.1>>" + msg);
    }

}
